class Campaigns::Order < ApplicationRecord
  belongs_to :member
  has_one :appointment, class_name: 'Campaigns::Appointment'
  has_one :running_account, class_name: "Transaction", foreign_key: :order_no, primary_key: :order_no

  enum status: {deleted: -2, canceled: -1, pending: 0, paid: 1, refunded: 2}
  enum source: {wx: '微信', app: '应用'}
  attr_accessor :sku_id, :coupon_id, :quantity, :remark, :paid_at
  ransacker :status, formatter: proc {|v| statuses[v]} do |parent|
    parent.table[:status]
  end
end
